@extends("admin.layouts.main")
<style>
    .card-body .form-group {
        width: 28%;
    }
    @media screen and (max-width: 1024px) {
        .card-body .form-group {
            width: 100% !important;
        }
    }
    .show-item {
        top: 40px;
        width: 75%;
        right: 15px;
        z-index: 10;
        background: white;
        overflow: hidden;
        display: none;
    }
    .showMsg li {
        padding-bottom: 5px;
        cursor: pointer;
        padding: 10px 8px;
        margin: 2px 0;
    }
    .showMsg li:hover {
        background-color: #f2f2f2;
    }
    input::-webkit-input-placeholder { /* WebKit browsers */
        font-size: 13px;
    }
    input:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
        font-size: 13px;
    }
    input:-ms-input-placeholder { /* Internet Explorer 10+ */
        font-size: 13px;
    }
</style>
@section("content")
<div class="container-fiuld p-3" id="app">
    <div class="card">
        <div class="card-body">
            <div class="pt-2 pb-2 d-flex justify-content-between align-items-center"
                 style="background-color:#f2f2f2;font-size:18px;">
                <h4 class="pl-2">添加公告</h4>
                <a href="{{ route('announ.index') }}" class="btn btn-link">返回</a>
            </div>
            <form class="layui-form mt-3">
                <div class="row align-items-center mb-3">
                    <div class="col-2 text-right">
                        <label class="mb-0">标题:</label>
                    </div>
                    <div class="col-6">
                        <input type="text" class="form-control" name="title" required lay-verify="required" id="title" placeholder="请输入标题"/>
                    </div>
                </div>
                <div class="row align-items-center mb-3">
                    <div class="col-2 text-right">
                        <label class="mb-0">内容:</label>
                    </div>
                    <div class="col-6">
                        <textarea class="form-control" name="content" id="content" lay-verify="required" placeholder="请输入内容" rows="20"></textarea>
                    </div>
                </div>
				@if(in_array('announ.createadd', $menuRule))
                <div class="col-6 offset-2 text-center">
                    <button class="layui-btn" lay-submit lay-filter="create-announ" data-url="{{ route('announ.createadd') }}" data-type="POST">提交
                    </button>
                    <button type="reset" class="layui-btn layui-btn-danger">重置</button>
                </div>
				@endif
            </form>
        </div>
    </div>
</div>
@endsection
@section("js")
<script src="{{ asset('kindeditor/kindeditor-min.js') }}"></script>
<script src="{{ asset('kindeditor/lang/zh_CN.js') }}"></script>
<script>
    //数据操作    
    layui.use(['form', 'oriagain', 'layer','ori'], function () {
        var form = layui.form, oriagain = layui.oriagain, $ = layui.$, layer = layui.layer,ori = layui.ori;
        form.on('submit(create-announ)', function (data) {
            $("[name=content]").val(content);
            oriagain.submit($(this), data.field, function () {
                var index = layer.open({
                    title: '结果',
                    content: '添加成功',
                    btn: ["继续添加", "返回列表"],
                    btn1: function () {
                        $('.layui-form')[0].reset();
                        layer.close(index);
                    },
                    btn2: function () {
						window.location.href = "{{ route('announ.index') }}";
                    }
                });
            });
            return false;
        });
    })
</script>
<script>
	// 编辑器
	var uploadJson = '';
	var fileManagerJson = '';
	var editor;
	KindEditor.ready(function (K) {
		editor = K.create("#content", {
			allowFileManager: true,
			uploadJson: uploadJson,
			fileManagerJson: fileManagerJson,
			afterBlur: function () {
				this.sync();
			}
		});
	});
</script>	
@endsection
